package com.bwie.controller;

import com.bwie.pojo.Result;
import com.bwie.pojo.Store;
import com.bwie.service.StoreService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("store")
public class StoreController {

    @Autowired
    private StoreService storeService ;

    /**
     * 跳转列表页面
     * @return
     */
    @RequestMapping("/toList")
    public String toList(){
        return "/store/list";
    }

    /**
     * 列表页面
     * @param store
     * @return
     */
    @RequestMapping("/list")
    @ResponseBody
    public Result<PageInfo<Store>> selectList(Store store){
        return storeService.selectList(store);
    }

    /**
     * 逻辑删除
     * @param store
     * @return
     */
    @RequestMapping("toDelete")
    @ResponseBody
    public Result doDelete(@RequestBody Store store){
        storeService.toDelete(store);
        return Result.success("删除成功");
    }

    /**
     * 查询是否有关联
     * @param sid
     * @return
     */
    @RequestMapping("selectOwner")
    @ResponseBody
    public Result selectOwner(Integer sid){
        storeService.selectOwner(sid);
        return Result.success();
    }

    @RequestMapping("selectOneByNum")
    @ResponseBody
    public Result<Store> selectOneByNum(String storeNum){
        return storeService.selectOneByNum(storeNum);
    }

}
